/// 新闻模型
class NewsItem {
  final String id;
  final String title;
  final String summary;
  final String content;
  final String category;
  final DateTime publishedAt;

  NewsItem({
    required this.id,
    required this.title,
    required this.summary,
    required this.content,
    required this.category,
    required this.publishedAt,
  });

  factory NewsItem.fromJson(Map<String, dynamic> json) {
    return NewsItem(
      id: json['id'].toString(),
      title: json['title'] ?? '',
      summary: json['summary'] ?? json['body'] ?? '',
      content: json['content'] ?? json['body'] ?? '',
      category: json['category'] ?? '通用',
      publishedAt: DateTime.now(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'summary': summary,
      'content': content,
      'category': category,
      'publishedAt': publishedAt.toIso8601String(),
    };
  }
}
